
var webpack = require("webpack");
var path = require("path");

// 将require css文件提取到header中

var SpritesmithPlugin = require('webpack-spritesmith');
//
// var devVendor = [
//   'react',
//   'redux',
//   'react-dom',
//   'react-redux',
//   'redux-logger',
//   'react-router',
//   'material-ui',
//   'redux-devtools',
//   'react-router-redux',
//   'react-tap-event-plugin',
//   'redux-devtools-dock-monitor',
//   'redux-devtools-log-monitor',
//   'react-addons-css-transition-group'
// ];

var config = {
    context: __dirname,
    entry: {
        index: ['./src/index.js', 'webpack/hot/dev-server']
    },
    output: {
        path: path.join(__dirname, "dist"),
        publicPath: "dist/", // relative path for github pages
        filename: "[name].js", // no hash in main.js because index.html is a static page
        chunkFilename: 'chunk/[name].[chunkhash:5].js',
    },
    // recordsOutputPath: path.join(__dirname, "records.json"),
    module: {
        loaders: [{
            test: /\.js?$/,
            exclude: /(node_modules)/,
            loaders: [
              'babel?presets[]=react&presets[]=es2015&presets[]=stage-2&presets[]=stage-3',
              // 'webpack-module-hot-accept'
            ],
            // loader: 'babel', // 'babel-loader' is also a legal name to reference
            // query: {
            //     presets: ['react', 'es2015', "stage-2", "stage-3"],
            // }
        }, {
            test: /\.scss$/,
            loader: 'style-loader!css-loader!sass-loader'
        }]
    },
    devtool: 'source-map',
    plugins: [
      new webpack.DefinePlugin({
        'NODE_ENV': '"development"',
        'process.env': {
          'NODE_ENV': '"development"'
        },
        // $: 'jquery',
        // jQuery: 'jquery'
      }),
      // new webpack.optimize.CommonsChunkPlugin({
      //   name: "vendor",
      //   // filename: "vendor.js"
      //   // (Give the chunk a different name)
      //   minChunks: Infinity,
      // }),
      new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 20 }),
      new webpack.optimize.OccurenceOrderPlugin(),
      new webpack.HotModuleReplacementPlugin(),
      new webpack.NoErrorsPlugin(),
      new webpack.DllReferencePlugin({
        context: __dirname,
        manifest: require('./libs/manifest.json'),
      }),
    ],
    fakeUpdateVersion: 0
};


module.exports = config;
